using UnityEngine;
using UnityEngine.UI;

public class ScoreManager : MonoBehaviour {

    [SerializeField] private Text currentScoreText;
    [SerializeField] private Text highScoreText;

    private float currentScore = 0f;

    void Start()
    {
        highScoreText.text = PlayerPrefs.GetFloat("HIGHSCORE", 0f).ToString("0");
    }

    void Update()
    {
        if (GameManager.instance.isGameActive != false) {
            currentScore += 10f * Time.deltaTime;
            currentScoreText.text = currentScore.ToString("0");
        }

        if (currentScore > PlayerPrefs.GetFloat("HIGHSCORE", 0f)) {
            PlayerPrefs.SetFloat("HIGHSCORE", currentScore);
            highScoreText.text = currentScore.ToString("0");
        }
    }
}
